<template>
  <el-card>
    <!-- <el-button @click="aaa">
      123
    </el-button> -->
    <el-table :data="managelist" style="width: 100%">
      <el-table-column prop="rangeName" label="靶场名称" width="180"> </el-table-column>
      <el-table-column prop="rangePrice" label="靶场价格" width="280"> </el-table-column>
      <el-table-column prop="rdId" label="靶场难度">
        <template slot-scope="scope">
          <span v-if="scope.row.rdId === 0">困难</span>
          <span v-else>简单</span>
        </template>
      </el-table-column>
      <el-table-column prop="rangeVip" label="靶场vip">
        <template slot-scope="scope">
          <span v-if="scope.row.rangeVip === 0">普通</span>
          <span v-else>VIP</span>
        </template>
      </el-table-column>
      <el-table-column prop="rangeImg" label="靶场图片" align="center">
        <template slot-scope="scope">
          <el-avatar :size="50" :src="scope.row.rangeImg"></el-avatar>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" width="180px">
        <template slot-scope="scope">
          <el-button type="primary" size="mini" icon="el-icon-edit" @click="Approved(scope)">审核通过</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination background layout="total, sizes, prev, pager, next, jumper" :total="total" :page-size="query.pageSize"
      :current-page.sync="query.currentPage" :page-sizes="[5, 10, 15, 20]" @size-change="changePageSize"
      @current-change="changeCurrentPage">
    </el-pagination>
  </el-card>
</template>
  
<script>
import { createNamespacedHelpers } from "vuex";
const { mapState: mapuserinfostate, mapMutations } = createNamespacedHelpers("userinfo")
const { mapMutations: mapaaa } = createNamespacedHelpers("tags");
export default {
  data() {
    return {
      managelist: [],
      total: 0,
      query: {
        pageSize: 10,
        currentPage: 1,
        rangeState: 0
      }
    };
  },
  methods: {
    ...mapMutations(["letmessageominus"]),
    ...mapaaa(["addTabs"]),
    aaa() {
      this.letmessageominus()
    },
    async getprocess() {
      const result = await this.$api.ranges.selType(this.query);
      console.log("未通过审核的数据", result.data.rangeeList1);
      if (result.code == 200) {
        // this.letmessageominus()
      }
      this.total = result.data.total
      this.managelist = result.data.rangeeList1

    },
    changeCurrentPage(args) {
      console.log("args", args);
      this.query.currentPage = args;
      this.getlog();
    },
    changePageSize(args) {
      console.log("args2", args);
      this.query.pageSize = args;
      this.getlog();
    },
    async Approved(args) {
      const obj = {
        rangeId: Number(args.row.rangeId),
        rangeState: 1
      }
      console.log("userId---", obj);
      const result = await this.$api.ranges.deleteRange(obj);
      console.log("result222", result);
      if (result.code == 200) {
        this.$message.success("审核通过");
        this.letmessageominus()
        this.getprocess();
      }
    }
  },
  //   beforeRouteEnter(to,from,next){
  //         next(vm=>{
  //            vm.addTabs(to)
  //         })
  //  },
  created() {
    this.getprocess();
  },
};
</script>
  
<style scoped lang="scss"></style>